<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        * {
            padding: 0;
            margin: 0;
            border: 0;
            box-sizing: border-box;
        }
        .wrapper {
            min-width: 400px;
            max-width: 800px;
            display: flex;
            justify-content: flex-end;
        }
        .avatar {
            width: 48px;
            height: 48px;
            border-radius: 50px;
            background-color: #00aeec;
            margin-right: 8px;
        }
        .wrapper input {
            outline: none;
            border: 1px solid transparent;
            border-radius: 5px;
            resize: none;
            background: #f5f5f5;
            flex: 1;
            padding: 10px;
            transition: all 0.5s;
            height: 48px;
        }
        .wrapper input:focus {
            border-color: #e4e4e4;
            background: #fff;
            height: 70px;
        }
        .wrapper button {
            background-color: #00aeec;
            color: #fff;
            border: none;
            border-radius: 5px;
            margin-left: 10px;
            width: 70px;
            cursor: pointer;
        }
        .wrapper .total {
            margin-right: 80px;
            color: #999;
            margin-top: 5px;
            opacity: 0;
            transition: all 0.5s;
        }
        .list {
            min-width: 400px;
            max-width: 800px;
            display: flex;
        }
        .list .item {
            width: 100%;
            display: flex;
        }
        .list .item .info {
            flex: 1;
            border-bottom: 1px dashed #e4e4e4;
            padding-bottom: 10px;
        }
        .list .item .name {
            color: #FB7299;
            font-size: 14px;
            font-weight: bold;
        }
        .list .item .text {
            color: #333;
            padding: 10px 0;
        }
        .list .item .time {
            color: #999;
            font-size: 12px;
        }

    </style>
</head>
<body>
    <div class="wrapper">
        <i class="avatar"></i>
        <input id="tx" placeholder="发一条友善的评论" rows="2" maxlength="200"/>
        <button>发布</button>
    </div>
    <div class="wrapper">
        <span class="total">0/200字</span>
    </div>
    <div class="list">
        <div class="item" style="display: none;">
          <i class="avatar"></i>
          <div class="info">
            <p class="name">清风徐来</p>
            <p class="text">大家都辛苦啦，感谢各位大大的努力，能圆满完成真是太好了[笑哭][支持]</p>
            <p class="time">2022-10-10 20:29:21</p>
          </div>
        </div>
      </div>

    <script>
        const input = document.querySelector('.wrapper input')
        const total = document.querySelector('.wrapper .total')
        const btn = document.querySelector('.wrapper button')
        const item  = document.querySelector('.list .item')
        const contentP = document.querySelector('.list .item .text')
        input.addEventListener('focus', function(){
            total.style.opacity = 1
        })
        input.addEventListener('blur', function(){
            total.style.opacity = 0
        })
        input.addEventListener('input', function(e){
            total.innerHTML = `${e.target.value.length}/200字`
        })
        btn.addEventListener('click', function(){
            contentP.innerHTML = input.value
            item.style.display = 'block'
        })
        input.addEventListener('keyup', function(e){
            if (e.key == 'Enter'){
                btn.click()
                e.target.value = ''
            }
        })
    </script>

</body>
</html>